package org.hiucung.localmusicdemo.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.module.LoadMoreModule;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.hiucung.localmusicdemo.R;
import org.hiucung.localmusicdemo.bean.LocalMusicBean;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class QQMusicAdapter extends BaseQuickAdapter<LocalMusicBean, BaseViewHolder> implements LoadMoreModule {

    TextView tvSinger;
    TextView tvSongTv;
    ImageView ivCover;

    public QQMusicAdapter(int layoutResId, @Nullable List<LocalMusicBean> data) {
        super(R.layout.item_search_music, data);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, LocalMusicBean localMusicBean) {
        tvSinger = baseViewHolder.getView(R.id.tvSub);
        tvSongTv = baseViewHolder.getView(R.id.tvTitle);
        ivCover = baseViewHolder.getView(R.id.ivCover);

        tvSinger.setText(localMusicBean.getSinger());
        tvSongTv.setText(localMusicBean.getSong());
        //通过 glide 获取应用的封面图标
        Glide.with(getContext()).load(localMusicBean.getAlbumUrl()).into(ivCover);
    }
}
